Let's talk about managing
performance with Google Cloud's Application Performance Management
or APM tools. APM includes advanced tools
to help developers reduce latency and cost for every application. As a developer, how do you make
your applications faster and more reliable? By understanding in detail
how they behave in production. APM uses some of the same tools used by Google's own site
reliability engineering or SRE teams, giving you insights
into how your code runs. This lets you take action
to optimize code and fix problems regardless of the cloud
you're using. All of the APM tools work with code
and applications running on any cloud or even on-premises
infrastructure. No matter where you
run your application, you now have a consistent, reasonably priced
APM tool kit to monitor and manage application performance.
Google charges for APM tools based only on the amount
of data collected. Generous free tiers make
APM accessible for any project. Cloud Trace is a distributed
tracing system that collects latency data
from your applications and displays it
in the Google Cloud Console. You can track how requests
propagate through your application and receive detailed near-real-time
performance insights. Cloud Trace
automatically analyzes all of your application's traces
to generate in-depth latency reports, surfacing performance
degradations. Cloud Trace can capture
traces from all of your VMs, containers and App Engine projects. Using Trace, you can inspect
detailed latency information for a single request,
review aggregate latency for your entire application. Using the various tools
and filters provided, you can quickly find
where bottlenecks are occurring and more quickly
identify the root causes. Cloud Trace is based
on the tools used to keep Google services
running at extreme scale. Trace continuously gathers
and analyzes trace data from your project to automatically
identify recent changes to your
application's performance. These latency distributions
available through the analysis reports feature can be
compared over time or versions, and Cloud Trace will
automatically alert you if it detects a significant shift
in your app's latency profile. Cloud Trace's language-specific SDKs
can analyze projects running on VMs, even those not running
in Google Cloud. The Trace SDK is currently available
for Java, Node.js, Ruby and Go. And the Trace API
can be used to submit and retrieve trace data
from any source. A Zipkin collector
is also available, which allows Zipkin tracers
to submit data to Cloud Trace. Traces are automatically captured
for projects running on App Engine. Because Cloud Trace collects
latency data from App Engine, HTTP/s load balancers and applications
instrumented with the Cloud Trace API, it can help you answer
the following questions. How long does it take my application
to handle a given request? Why is it taking my application
so long to handle a request? Why do some of my requests
take longer than others? What is the overall latency
of requests to my application? Has latency for my application
increased or decreased over time? What can I do to reduce
application latency? And what are my application's
dependencies? After the Cloud Trace agent
has collected trace data, you can view and analyze
that data in near real time in the Cloud Trace interface.
The interface contains three windows: overview, trace list
and analysis reports. The insights pane displays
a list of performance insights for your application
if applicable. This pane highlights
common problems in applications such as consecutive calls
to a function that if batched
might be more efficient. The recent traces pane displays
the most recent traces. For each, the latency,
URI and time are displayed. You can use this summary
to understand the current activity
in your application. The most frequent URIs
and most frequent RPCs from the previous date are listed,
along with the average latency. If you click a link
in either of these tables, you open a trace list window
where you can view latency as a function of time and investigate
details of any individual trace. The chargeable trace spans pane
displays the number of spans ingested in the current calendar month
and the total for the previous month. You can use this information to monitor
your costs for using Cloud Trace. The daily analysis reports pane
displays latency data for the previous day in comparison
to the latency data from 7 days prior. You can also create your own
analysis reports to select which traces you want
included in the report. Cloud Profiler monitors CPU
and heap to help you identify latency and inefficiency
using interactive graphical tools so you can improve
application bottlenecks and reduce resource consumption. Google uses the same technology
every day to identify inefficiently written code
on services like Search and Gmail. Poorly performing code
increases the latency and cost of applications
and web services every day, often without anyone knowing
or doing anything about it. Cloud Profiler changes this
by continuously analyzing the performance of CPU
or memory-intensive functions executed across an application. Cloud Profiler presents
the call hierarchy and resource consumption of the relevant function
in an interactive flame graph that helps developers understand
which paths consume the most resources and the different ways in which
their code is actually called. While it's possible to measure code
performance in development environments, the results generally don't map well
to what's happening in production. Many production profiling techniques
either slow down code execution or only inspect
a small subset of a code base. Cloud Profiler uses
statistical techniques and extremely low impact
instrumentation that runs across all
production application instances to provide a complete picture
of an application's performance without slowing it down. Cloud Profiler allows developers
to analyze applications running anywhere,
including Google Cloud, other cloud platforms or on-premises
with support for Java, Go, Node.js and Python. A full explanation of language
and platform support is available
in the documentation. In order to use Cloud Profiler,
you install a profiling agent on the virtual machines
where your application runs. The agent typically comes
as a library that you attach to your application
when you run it. The agent collects
profiling data as the app runs. Cloud Profiler
is a statistical profiler, so the agent
is not always active. Cloud Profiler creates a single profile
by collecting profiling data, usually for 10 seconds once a minute
for a single instance of the configured service
in a single Compute Engine zone. After each instance
of the agent starts, it notifies the profiler back end
that it's ready to capture data, and then the agent idles until
it receives a reply from the back end specifying the type of profile
it captured. If you have 10 instances of a service
running in the same deployment, you create 10 profiling agents. However, these agents
are idle most of the time. Over a 10-minute period,
you can expect 10 profiles. Each agent receives one reply
for each profile type on average. There is some randomization involved,
so the actual number may vary. The overhead of the CPU
and heap allocation profiling at the time of the data
collection is less than 5 percent. Amortized over the execution time and across multiple replicas
of a service, the overhead is commonly
less than 0.5 percent, making it an affordable option for always-on profiling
in production systems. After the agent has collected
some profiling data, you can use the profiler interface
to see how the statistics for CPU and memory usage correlate
with areas of your application. With Error Reporting, you can debug your application
in development and also troubleshoot
errors in production. Error reporting displays errors
that have occurred in your applications. You can view the stack trace
to determine where the error occurred.